import Vue from 'vue'
import VueRouter from 'vue-router'



Vue.use(VueRouter)

const routes = [
  {
    path: '/',
    redirect: '/discover'

  },
  // {
  //   path: '/404',
  //   name: '404',
  //   component: () => import('../views/404/404.vue')
  // },
  {
    path: '/discover',
    name: 'Discover',
    component: () => import('../views/discover/discover.vue'),
    redirect: '/discover/recommend',
    children: [
      {
        path: '/discover/recommend',
        name: 'Discover',
        component: () => import('../views/recommend/recommend.vue')
      },
      {
        path: '/discover/toplist',
        name: 'Discover',
        component: () => import('../views/toplist/topList.vue')
      },
      {
        path: '/discover/playlist',
        name: 'Discover',
        component: () => import('../views/playlist/playList.vue')
      },
      // 歌单详情
      {
        path: '/playlist',
        name: 'Discover',
        component: () => import('../views/playlist/playListDetail.vue')
      },
      // 歌曲详情
      {
        path: '/song',
        name: 'Discover',
        component: () => import('../views/song/song.vue')
      },
      // mv
      {
        path: '/mv',
        name: 'Discover',
        component: () => import('../views/discover/mv/mv.vue')
      },
      {
        path: '/discover/djradio',
        name: 'Discover',
        component: () => import('../views/djradio/djRadio.vue'),
        children: [
          {
            path: '/discover/djradio/category',
            name: 'Discover',
            component: () => import('../views/djradio/components/djRouter.vue')
          }
        ]
      },
      {
        path: '/discover/artist',
        name: 'Discover',
        component: () => import('../views/artist/artist.vue')
      },
      {
        path: '/discover/album',
        name: 'Discover',
        component: () => import('../views/album/album.vue')
      }

    ]

  },
  // 用户信息
  {
    path: '/user',
    name: "User",
    component: () => import('../views/user/user.vue'),
    children: [
      {
        path: '/user/update',
        component: () => import('../views/user/userUpdate.vue'),
      }
    ]
  },
  {
    path: '/my',
    name: 'My',
    component: () => import('../views/my/my.vue')
  }

]



const router = new VueRouter({
  routes,
  scrollBehavior() {
    return { x: 0, y: 0 }
  }
})

router.beforeEach((to, from, next) => {
  document.body.scrollTop = 0;
  next()
});

export default router
